package com.jxw.launcher.view.brokenrecyclerview;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import com.jxw.launcher.R;
import com.jxw.launcher.model.UserKnowledgeBean;
import com.jxw.launcher.util.ApkJumpUtil;
import com.jxw.utils.ScreenUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* loaded from: classes.dex */
public class BrokenLineView1 extends RecyclerView {
    private Adapter adapter;
    private List<UserKnowledgeBean.DataBean> data;
    private Context mContext;
    private int maxValue;
    private int minValue;
    private String strChapterId;
    private String strEditionId;
    private String strgradeId;
    private int subjectId;

    public BrokenLineView1(Context context) {
        super(context);
        this.data = new ArrayList();
        this.strgradeId = "";
        this.strEditionId = "";
        this.strChapterId = "";
        init();
    }

    private void init() {
        setLayoutManager(new LinearLayoutManager(getContext(), 0, false));
        this.adapter = new Adapter();
        setAdapter(this.adapter);
    }

    public void setData(Context context, List<UserKnowledgeBean.DataBean> list, int i, String str, String str2, String str3) {
        this.mContext = context;
        this.subjectId = i;
        this.strgradeId = str;
        this.strEditionId = str2;
        this.strChapterId = str3;
        List<UserKnowledgeBean.DataBean> list2 = this.data;
        if (list2 != null) {
            list2.clear();
            this.data.addAll(list);
            Collections.sort(list);
            this.minValue = list.get(0).getPositionType();
            this.maxValue = list.get(list.size() - 1).getPositionType();
            this.adapter.notifyDataSetChanged();
        }
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    /* loaded from: classes.dex */
    public class Adapter extends RecyclerView.Adapter<ViewHolder> {
        Adapter() {
        }

        @Override // android.support.v7.widget.RecyclerView.Adapter
        public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
            Item1 item1 = new Item1(BrokenLineView1.this.getContext());
            item1.setMinValue(BrokenLineView1.this.minValue);
            item1.setMaxValue(BrokenLineView1.this.maxValue);
            item1.setLayoutParams(new RecyclerView.LayoutParams(ScreenUtils.dp2px(BrokenLineView1.this.mContext, BrokenLineView1.this.mContext.getResources().getDimension(R.dimen.broken_line_item_width)), -1));
            return new ViewHolder(item1);
        }

        @Override // android.support.v7.widget.RecyclerView.Adapter
        public void onBindViewHolder(ViewHolder viewHolder, int i) {
            viewHolder.item.setDataTotalSize(BrokenLineView1.this.data.size());
            if (i == 0) {
                viewHolder.item.setDrawLeftLine(false);
            } else {
                viewHolder.item.setDrawLeftLine(true);
                StringBuilder sb = new StringBuilder();
                sb.append("setlastValue-1-");
                sb.append(i);
                sb.append("*");
                int i2 = i - 1;
                sb.append(((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i2)).getPositionType());
                Log.d("lyx", sb.toString());
                viewHolder.item.setlastValue((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(BrokenLineView1.this.data.size() - 1), ((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i2)).getPositionType());
            }
            viewHolder.item.setCurrentValue((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i), ((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i)).getPositionType());
            Log.d("lyx", "setCurrentValue-1-" + i + "*" + ((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i)).getPositionType());
            if (i == BrokenLineView1.this.data.size() - 1) {
                viewHolder.item.setDrawRightLine(false);
            } else {
                viewHolder.item.setDrawRightLine(true);
                int i3 = i + 1;
                viewHolder.item.setNextValue((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i3), ((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i3)).getPositionType());
                Log.d("lyx", "setNextValue-1-" + i + "*" + ((UserKnowledgeBean.DataBean) BrokenLineView1.this.data.get(i3)).getPositionType());
            }
            viewHolder.item.setOnClickListener(new View.OnClickListener() { // from class: com.jxw.launcher.view.brokenrecyclerview.BrokenLineView1.Adapter.1
                @Override // android.view.View.OnClickListener
                public void onClick(View view) {
                    ApkJumpUtil.aiTiku(BrokenLineView1.this.mContext, "", 1, -1, BrokenLineView1.this.subjectId);
                }
            });
        }

        @Override // android.support.v7.widget.RecyclerView.Adapter
        public int getItemCount() {
            return BrokenLineView1.this.data.size();
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        /* loaded from: classes.dex */
        public class ViewHolder extends RecyclerView.ViewHolder {
            Item1 item;

            public ViewHolder(View view) {
                super(view);
                this.item = (Item1) view;
            }
        }
    }
}
